CxGrpGrid Methods
The CxGrpGrid object contains the following methods:
AboutBox
The AboutBox method displays an About dialog box for the control.
Syntax
AboutBox()
Example
The following examples launch an About dialog box for the control.
Sub ShowAboutBox()
<Object>.AboutBox
End Sub
Sub ButtonTool_EventClick()
Dim This : Set This = ButtonTool
<Object>.AboutBox
End Sub
ClearCols
The ClearCols method clears the configuration XML for all columns, leaving them blank. Do not call this method when the grid is in Run mode.
Syntax
ClearCols()
Example
The following example loads CxGrpGrid with UDCs for the selected facility. This example is taken from the CxGrpNavBar and CxGrpGrid Example.
Sub LoadGrid()
Dim arrUdcList
Dim iLowerBound
Dim iUpperBound
Dim strFacTag
Dim strUis
strUis = FacNavBar.X.SiteService
strFacTag = FacNavBar.X.GetSelectedTargetFacTag()
If strUis = "" Then
msgbox "Set the Site.Service"
Exit Sub
End If
If strFacTag = "" Then
msgbox "Invalid FacilityTag (" + strFacTag + ")"
Exit Sub
End If
Dim aryFacTag, strFacility
aryFacTag = Split(strFacTag, "::")
strFacility = aryFacTag(1)
'
' Get the udc list for this facility.
'
GetUdcList strFacTag, arrUdcList
iLowerBound = 0
iUpperBound = ubound(arrUdcList)
'
' Load up the grid rows/columns
'
Dim i, j, itemid
CxGrpGrid.x.Stop
CxGrpGrid.x.ClearRows
CxGrpGrid.x.ClearColumns
CxGrpGrid.x.Columns = 4
For j=0 To 3
CxGrpGrid.x.ColSiteService(j) = strUis
CxGrpGrid.x.ColFacility(j) = strFacility
Next
CxGrpGrid.x.ColLabelText(0) = "Description"
CxGrpGrid.x.ColDisplayItem(0) = 10007
CxGrpGrid.x.ColLabelText(1) = "Value"
CxGrpGrid.x.ColDisplayItem(1) = 10001
CxGrpGrid.x.ColLabelText(2) = "Units"
CxGrpGrid.x.ColDisplayItem(2) = 10008
CxGrpGrid.x.ColLabelText(3) = "Time"
CxGrpGrid.x.ColDisplayItem(3) = 10002
For i=iLowerBound To iUpperBound
CxGrpGrid.x.RowUdc(i) = arrUdcList(i)
CxGrpGrid.x.RowLabelText(i) = CxGrpGrid.x.RowUdc(i)
Next
CxGrpGrid.x.Start
End Sub
ClearRows
The ClearRows method clears the configuration XML for all rows, leaving them blank. Do not call this method when the grid is in Run mode.
Syntax
ClearRows()
Example
The following example loads CxGrpGrid with UDCs for the selected facility.This example is taken from the CxGrpNavBar and CxGrpGrid Example.
Sub LoadGrid()
Dim arrUdcList
Dim iLowerBound
Dim iUpperBound
Dim strFacTag
Dim strUis
strUis = FacNavBar.X.SiteService
strFacTag = FacNavBar.X.GetSelectedTargetFacTag()
If strUis = "" Then
msgbox "Set the Site.Service"
Exit Sub
End If
If strFacTag = "" Then
msgbox "Invalid FacilityTag (" + strFacTag + ")"
Exit Sub
End If
Dim aryFacTag, strFacility
aryFacTag = Split(strFacTag, "::")
strFacility = aryFacTag(1)
'
' Get the udc list for this facility.
'
GetUdcList strFacTag, arrUdcList
iLowerBound = 0
iUpperBound = ubound(arrUdcList)
'
' Load up the grid rows/columns
'
Dim i, j, itemid
CxGrpGrid.x.Stop
CxGrpGrid.x.ClearRows
CxGrpGrid.x.ClearColumns
CxGrpGrid.x.Columns = 4
For j=0 To 3
CxGrpGrid.x.ColSiteService(j) = strUis
CxGrpGrid.x.ColFacility(j) = strFacility
Next
CxGrpGrid.x.ColLabelText(0) = "Description"
CxGrpGrid.x.ColDisplayItem(0) = 10007
CxGrpGrid.x.ColLabelText(1) = "Value"
CxGrpGrid.x.ColDisplayItem(1) = 10001
CxGrpGrid.x.ColLabelText(2) = "Units"
CxGrpGrid.x.ColDisplayItem(2) = 10008
CxGrpGrid.x.ColLabelText(3) = "Time"
CxGrpGrid.x.ColDisplayItem(3) = 10002
For i=iLowerBound To iUpperBound
CxGrpGrid.x.RowUdc(i) = arrUdcList(i)
CxGrpGrid.x.RowLabelText(i) = CxGrpGrid.x.RowUdc(i)
Next
CxGrpGrid.x.Start
End Sub
Export
The Export method exports the contents of the grid to a temporary CSV file and opens the file with the default spreadsheet viewer for the user to view and save to disk.
Syntax
Export()
Example
The following example saves the grid as a spreadsheet and opens it.
FindCol
The FindCol method returns the column number matching the specified label text.
Syntax
FindCol(LabelText As String) As Long
Parameters
| Parameter | Required | Description |
|---|---|---|
|
LabelText |
Yes |
The column label text specifying the column to return. |
Example
The following example displays the number of the column labeled "REAL8".
GetCellValue
The GetCellValue method returns the value for a cell.
Syntax
GetCellValue(Column As Long, Row As Long) As Variant
Parameters
| Parameter | Required | Description |
|---|---|---|
|
Column |
Yes |
The zero-based index of the column to select. |
|
Row |
Yes |
The zero-based index of the row to select. |
Example
The following example displays the cell value in a message box when a cell is double-clicked.
Sub GrpGrid_EventDClick(Column, Row)
Dim This : Set This = GrpGrid
Dim strMsg
strMsg = "Cell Details" + vbCr + vbCr
strMsg = strMsg + "Site.Service: " + GrpNavBar.X.SiteService + vbCr
strMsg = strMsg + "Col UDC: " + GrpGrid.X.ColUdc(Column) + vbCr
strMsg = strMsg + "Row Facility: " + GrpGrid.X.RowFacility(Row) + vbCr
strMsg = strMsg + "Cell Value: " + GrpGrid.X.GetCellValue(Column, Row)
MsgBox strMsg
End Sub
GetDisplayColsXml
The GetDisplayColsXml method get the display columns as XML.
Syntax
GetDisplayColsXml() As String
Remarks
An example of the XML that this method will return is:
<XML>
<DisplayCols Col_0="0" Col_1="1" Col_2="2" Col_3="3" Count="4"/>
</XML>
Example
The following example shows the Column XML in edtMessageBox. See ClearCols for another example.
Sub GrpGrid_EventDClickCol(Column)
Dim This : Set This = ButtonTool
edtMessageBox.Text = GrpGrid.GetDisplayColsXml
End Sub
GetPointAttributeByCell
The GetPointAttributeByCell method queries a grid’s cache to retrieve a point or facility attribute for a cell by the cell's column and row number. This allows the retrieval of point and facility information that may have already been compiled elsewhere on a screen.
Syntax
GetPointAttributeByCell(Column As Long, Row As Long, attribute As String)
Example
The following example for GetPointAttributeByCell displays a prompt for the user to type in the point attribute they want to retrieve. It uses the values provided in the double-click event for Column and Row numbers. The retrieved point attribute is displayed in a message box.
Sub groupGridCntrl_EventDClick(Column, Row)
Dim This : Set This = groupGridCntrl
Dim strAttribute, varResult
strAttribute = InputBox("Attribute?")
varResult = groupGridCntrl.X.GetPointAttributeByCell(Column, Row, strAttribute)
MsgBox CStr(varResult),,"Attribute: " & strAttribute
End Sub
GetPointAttributeForTag
The GetPointAttributeForTag method queries a grid’s cache to retrieve a tag’s attribute from a point tag. This allows the retrieval of point and facility information that may have already been compiled elsewhere on a screen.
Syntax
GetPointAttributeForTag(pointTag As Variant, attribute As String)
Example
The following example for GetPointAttributeForTag displays a prompt for the user to type in the point attribute they want to retrieve.
It then uses the values provided in the right-click event for Column and Row with GetPointAttributeByCell to get the "tagfull" attribute, then uses that with the user-provided attribute in GetPointAttributeForTag. The retrieved point attribute is displayed in a message box.
Sub groupGridCntrl_EventRClick(Column, Row)
Dim This : Set This = groupGridCntrl
Dim strTag, varResult, strAttribute
strAttribute = InputBox("Attribute?")
strTag = groupGridCntrl.X.GetPointAttributeByCell(column, row, "tagfull")
varResult = groupGridCntrl.X.GetPointAttributeForTag(strtag, strAttribute)
MsgBox "Attribute: " & strAttribute & vbCr & CStr(varResult),,strTag
End Sub
GetPointTag
The GetPointTag method returns the point tag for an individual cell in the tool's grid. Its syntax is as follows:
GetPointTag(Column As Long, Row As Long) As Object
Example
The following example illustrates how to "catch" the return:
|
dim pTag Set pTag=groupgrid1.X.GetPointTag (1,0) |
Also see the PointTag object.
GetRows
The GetRows method returns the count of rows in the grid.
Syntax
GetRows() As Long
Example
The following example displays the number of rows in edtMessageBox.
Sub GrpGrid_EventDClickRow(Row)
Dim This : Set This = ButtonTool
edtMessageBox.Text = "There are " & GrpGrid.GetRows & " rows."
End Sub
GetSelectedRow
The GetSelectedRow method returns the zero-based index of the selected row or –1 if no row is currently selected.
Syntax
GetSelectedRow() As Long
Example
The following example displays the selected row in edtMessageBox every time a new row is clicked.
Sub GrpGrid_EventLClickRow(Row)
Dim This : Set This = ButtonTool
edtMessageBox.Text = "Row #" & GrpGrid.GetSelectedRow & " is selected."
End Sub
GetSingleSortColumn
The GetSingleSortColumn method returns the sort column in single column sort mode. This method is only used for a grid that has the Single Column option set for Sorting and Grouping in the OCX Properties.
Syntax
GetSingleSortColumn() As Long
Example
The following example displays the sort column in a message box.
GetSortOrder
The GetSortOrder method returns the sort order for the current sort mode. For a list of possible values returned by this method, see the ESortOrder Enumeration Table.
Syntax
GetSortOrder() As ESortOrder
Example
The following example displays the current sort order in a message box.
The Print method prints the contents of the control, grid, or viewer. When this method is called, the Print dialog box is shown to allow configuration.
Syntax
Print()
Example
The following method prints the grid contents.
Restart
For objects, the Restart method stops and restarts Run mode. For TheFrame/TheView, the Restart method restarts TheView with new site, service, and facility information, if applicable.
Syntax
Restart()
Example
The following example restarts GrpGrid.
Sub ButtonTool_EventClick()
Dim This : Set This = ButtonTool
GrpGrid.Restart
MsgBox "GrpGrid Restarted"
End Sub
SelectRow
The SelectRow method selects a specified grid row. This method will return false if the specified row does not exist or is unable to be selected.
Syntax
SelectRow(Row As Long) As Boolean
Parameters
| Parameter | Required | Description |
|---|---|---|
|
Row |
Yes |
The zero-based index of the row to select. |
Example
The following example selects the second row displayed.
SetCellValue
The SetCellValue method sets the value for a cell. This method will throw an error if the specified cell does not exist, or if the specified column does not permit user values.
Syntax
SetCellValue(Column As Long, Row As Long, UserValue As Variant)
Parameters
| Parameter | Required | Description |
|---|---|---|
|
Column |
Yes |
The zero-based index of the column to select. |
|
Row |
Yes |
The zero-based index of the row to select. |
|
UserValue |
Yes |
The value to set for the cell. |
Example
The following example sets the selected cell value to 0 when a custom context menu item is selected.
Sub GrpGrid_EventContextMenu(Col, Row, EventID)
Dim This : Set This = GrpGrid
If EventID = "CLEAR_CELL" Then
GrpGrid.X.SetCellValue Col, Row, 0
End If
End Sub
SetDisplayColsXml
The SetDisplayColsXml method sets the display columns from XML.
Syntax
SetDisplayColsXml(DisplayColsXml As String)
Parameters
| Parameter | Required | Description |
|---|---|---|
|
DisplayColsXml |
Yes |
An XML string specifying the display columns to set. |
Remarks
The following is an example of a valid XML for the DisplayColsXml parameter:
<XML>
<DisplayCols Col_0="0" Col_1="1" Col_2="2" Col_3="3" Count="4"/>
</XML>
Example
In the following example, the first method stores the Column XML in edtXML and the second method updates the columns with the changed XML.
Sub GetXml()
edtXML.Text = GrpGrid.GetDisplayColsXml
edtMessageBox.Text = "XML retrieved"
End Sub
Sub SetXml()
GrpGrid.SetDisplayColsXml(edtXML.Text)
edtMessageBox.Text = "XML changed"
End Sub
SetHistoryPlaybackMode
The SetHistoryPaybackMode method sets the history playback mode. This method is obsolete. It is automatically called by CygNet Studio when entering History Playback Mode.
Syntax
SetHistoryPlaybackMode(HistoryMode As Boolean)
Parameters
| Parameter | Required | Description |
|---|---|---|
|
HistoryMode |
Yes |
Enables or disables History Playback Mode. |
Example
The following example toggles History Playback Mode on and off.
Sub switchModes(mode)
If mode = False Then
GrpGrid.SetHistoryPlaybackMode(True)
mode = True
Else
GrpGrid.SetHistoryPlaybackMode(False)
mode = False
End If
edtMessageBox.Text = "History Playback Mode is set to " & mode
End Sub
SetHistoryPlaybackTime
The SetHistoryPlaybackTime method sets the history playback time. This method is obsolete. It is automatically called by CygNet Studio while in History Playback Mode.
Syntax
SetHistoryPlaybackTime(HistoryPlaybackTime As Date)
Parameters
| Parameter | Required | Description |
|---|---|---|
|
HistoryPlaybackTime |
Yes |
The timestamp of the requested data. |
Example
The following example sets the history time.
Sub changeTime()
Dim newTime
newTime = CDate(EditBox1.Text) 'ex. 4:00 PM 4/29/2023
GrpGrid.SetHistoryPlaybackTime(newTime)
MsgBox (newTime)
End Sub
SetSingleSort
The SetSingleSort method sets the sort column and order in single column sort mode. This method is only used for a grid that has the Single Column option set for Sorting and Grouping in the OCX Properties. This method will return false if the grid is not in single column sort mode, if the specified sort order is invalid, or if the specified column does not exist.
Syntax
SetSingleSort(Column As Long, SortOrder As ESortOrder) As Boolean
Parameters
| Parameter | Required | Description |
|---|---|---|
|
Column |
Yes |
The zero-based index of the column to set as the sort column. |
|
SortOrder |
Yes |
The sort order to set. For a list of possible values of this parameter, see the ESortOrder Enumeration Table. |
Example
The following example sets the first column to ascending sort mode.
SetSingleSortColumn
The SetSingleSortColumn method sets the sort order in single column sort mode. This method is only used for a grid that has the Single Column option set for Sorting and Grouping in the OCX Properties. This method will return false if the grid is not in single column sort mode, or if the specified column does not exist.
Syntax
SetSingleSortColumn(Column As Long) As Boolean
Parameters
| Parameter | Required | Description |
|---|---|---|
|
Column |
Yes |
The zero-based index of the column to set as the sort column. |
Example
The following example sets the first column as the sort column.
SetSortOrder
The SetSortOrder method sets the sort order for the current sort mode. This method will return false if the specified sort order is already in use by the grid, or if the specified sort order is invalid.
Syntax
SetSortOrder(SortOrder As ESortOrder) As Boolean
Parameters
| Parameter | Required | Description |
|---|---|---|
|
SortOrder |
Yes |
The sort order to set. For a list of possible values of this parameter, see the ESortOrder Enumeration Table. |
Example
The following example sets the grid to ascending sort mode.
ShowRowNumbers
The ShowRowNumbers method shows/hides row numbers. This method will return the previous state of row number visibility. That is, if row numbers were visible prior to calling this method, it will return true; otherwise, it will return false.
Syntax
ShowRowNumbers(Show As Boolean) As Boolean
Parameters
| Parameter | Required | Description |
|---|---|---|
|
Show |
Yes |
Set to true to show row numbers, or set to false to hide row numbers. |
Example
The following example shows row numbers on the grid.
Start
The Start method configures the control and starts Run mode.
Syntax
Start()
Example
The following example loads CxGrpGrid with UDCs for the selected facility. This example is taken from the CxGrpNavBar and CxGrpGrid Example.
Sub LoadGrid()
Dim arrUdcList
Dim iLowerBound
Dim iUpperBound
Dim strFacTag
Dim strUis
strUis = FacNavBar.X.SiteService
strFacTag = FacNavBar.X.GetSelectedTargetFacTag()
If strUis = "" Then
msgbox "Set the Site.Service"
Exit Sub
End If
If strFacTag = "" Then
msgbox "Invalid FacilityTag (" + strFacTag + ")"
Exit Sub
End If
Dim aryFacTag, strFacility
aryFacTag = Split(strFacTag, "::")
strFacility = aryFacTag(1)
'
' Get the udc list for this facility.
'
GetUdcList strFacTag, arrUdcList
iLowerBound = 0
iUpperBound = ubound(arrUdcList)
'
' Load up the grid rows/columns
'
Dim i, j, itemid
CxGrpGrid.x.Stop
CxGrpGrid.x.ClearRows
CxGrpGrid.x.ClearColumns
CxGrpGrid.x.Columns = 4
For j=0 To 3
CxGrpGrid.x.ColSiteService(j) = strUis
CxGrpGrid.x.ColFacility(j) = strFacility
Next
CxGrpGrid.x.ColLabelText(0) = "Description"
CxGrpGrid.x.ColDisplayItem(0) = 10007
CxGrpGrid.x.ColLabelText(1) = "Value"
CxGrpGrid.x.ColDisplayItem(1) = 10001
CxGrpGrid.x.ColLabelText(2) = "Units"
CxGrpGrid.x.ColDisplayItem(2) = 10008
CxGrpGrid.x.ColLabelText(3) = "Time"
CxGrpGrid.x.ColDisplayItem(3) = 10002
For i=iLowerBound To iUpperBound
CxGrpGrid.x.RowUdc(i) = arrUdcList(i)
CxGrpGrid.x.RowLabelText(i) = CxGrpGrid.x.RowUdc(i)
Next
CxGrpGrid.x.Start
End Sub
Stop
The Stop method stops Run mode.
Syntax
Stop()
Example
The following example loads CxGrpGrid with UDCs for the selected facility. This example is taken from the CxGrpNavBar and CxGrpGrid Example.
Sub LoadGrid()
Dim arrUdcList
Dim iLowerBound
Dim iUpperBound
Dim strFacTag
Dim strUis
strUis = FacNavBar.X.SiteService
strFacTag = FacNavBar.X.GetSelectedTargetFacTag()
If strUis = "" Then
msgbox "Set the Site.Service"
Exit Sub
End If
If strFacTag = "" Then
msgbox "Invalid FacilityTag (" + strFacTag + ")"
Exit Sub
End If
Dim aryFacTag, strFacility
aryFacTag = Split(strFacTag, "::")
strFacility = aryFacTag(1)
'
' Get the udc list for this facility.
'
GetUdcList strFacTag, arrUdcList
iLowerBound = 0
iUpperBound = ubound(arrUdcList)
'
' Load up the grid rows/columns
'
Dim i, j, itemid
CxGrpGrid.x.Stop
CxGrpGrid.x.ClearRows
CxGrpGrid.x.ClearColumns
CxGrpGrid.x.Columns = 4
For j=0 To 3
CxGrpGrid.x.ColSiteService(j) = strUis
CxGrpGrid.x.ColFacility(j) = strFacility
Next
CxGrpGrid.x.ColLabelText(0) = "Description"
CxGrpGrid.x.ColDisplayItem(0) = 10007
CxGrpGrid.x.ColLabelText(1) = "Value"
CxGrpGrid.x.ColDisplayItem(1) = 10001
CxGrpGrid.x.ColLabelText(2) = "Units"
CxGrpGrid.x.ColDisplayItem(2) = 10008
CxGrpGrid.x.ColLabelText(3) = "Time"
CxGrpGrid.x.ColDisplayItem(3) = 10002
For i=iLowerBound To iUpperBound
CxGrpGrid.x.RowUdc(i) = arrUdcList(i)
CxGrpGrid.x.RowLabelText(i) = CxGrpGrid.x.RowUdc(i)
Next
CxGrpGrid.x.Start
End Sub


